package com.ibiaoke.boss.controller;

import com.ibiaoke.common.base.Page;
import com.ibiaoke.common.response.Res;
import com.ibiaoke.customer.entity.Customer;
import com.ibiaoke.customer.entity.vo.CustomerVO;
import com.ibiaoke.customer.service.CustomerService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.Date;
import java.util.List;

/**
 * Created by Administrator on 2017/6/19.
 */
@Controller
public class CustomerController {
    @Autowired
    private CustomerService customerService;

    /**
     * 查询客户列表
     * @param customerUsername
     * @param customerNickname
     * @param customerMobile
     * @param customerEmail
     * @param page
     * @return
     */
    @ResponseBody
    @RequestMapping("/listCustomer")
    public Res listCustomer(String customerUsername, String customerNickname, String customerMobile, String customerEmail, Date startTime, Date endTime, Page page){
        List<Customer> customerList = customerService.listCustomer(customerUsername, customerNickname, customerMobile, customerEmail, startTime,endTime, page);
        return Res.create().addResponse("customerList", customerList).addResponse("page", page);
    }

    /**
     * 编辑Customer基本信息
     * @param customerVO (
     *                   customerId
     *                   customerNickname
     *                   customerMobile
     *                   customerEmail)
     * @return res
     */
    @ResponseBody
    @RequestMapping("/editCustomer")
    public Res editCustomer(CustomerVO customerVO) {
        customerService.editCustomer(customerVO);
        return Res.create();
    }
}
